﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace SteamFluentAPI.Infrastructure.Base
{
    public abstract class SteamMethod
    {
        private Dictionary<string, object> _parameters;

        protected void Add(string key, object value)
        {
            if (_parameters == null)
            {
                _parameters = new Dictionary<string, object>();
            }

            if (_parameters.Keys.Contains(key))
            {
                _parameters[key] = value;
            }
            else
            {
                _parameters.Add(key, value);
            }
        }

        public Dictionary<string, object> GetParameters()
        {
            if (_parameters == null)
            {
                return new Dictionary<string, object>();
            }
            return _parameters;
        }

        /// <summary>
        /// <para>The ISO639-1 language code for the language all localized strings should be returned in. 
        /// Not all strings have been translated to every language. If a language does not have a string, the English string will be returned instead. 
        /// If this parameter is omitted the string token will be returned for the strings.</para>
        /// </summary>
        /// <param name="languageCode"></param>
        public void Language(string languageCode)
        {
            Add("language", languageCode);
        }

        #region Hiding Methods

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override Boolean Equals(Object obj)
        {
            return base.Equals(obj);
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override Int32 GetHashCode()
        {
            return base.GetHashCode();
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override String ToString()
        {
            return base.ToString();
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public new Type GetType()
        {
            return base.GetType();
        }

        #endregion
    }

    public class SteamAppMethod : SteamMethod
    {
        /// <summary>
        /// AppID of game. (REQUIRED)
        /// </summary>
        /// <param name="appid"></param>
        [RequiredParameter("appid")]
        public void AppID(int appid)
        {
            Add("appid", appid);
        }
    }

    public class SteamGameMethod : SteamMethod
    {
        /// <summary>
        /// The ID of the game.
        /// </summary>
        /// <param name="appid"></param>
        [RequiredParameter("gameid")]
        public void GameID(long gameid)
        {
            Add("gameid", gameid);
        }
    }

    public class SteamIDMethod : SteamMethod
    {
        /// <summary>
        /// The 64 bit ID of the user to retrieve a list for. (REQUIRED)
        /// </summary>
        /// <param name="steamid"></param>
        [RequiredParameter("steamid")]
        public void SteamId(long steamid)
        {
            Add("steamid", steamid);
        }
    }

    public class SteamIDsMethod : SteamMethod
    {
        /// <summary>
        /// Comma-delimited list of SteamIDs. (REQUIRED)
        /// </summary>
        /// <param name="steamids"></param>
        [RequiredParameter("steamids")]
        public void SteamIds(params long[] steamids)
        {
            Add("steamids", steamids.ToDelimitedString());
        }
    }

    public class SteamIDandAppMethod : SteamAppMethod
    {
        /// <summary>
        /// The 64 bit ID of the user to retrieve a list for. (REQUIRED)
        /// </summary>
        /// <param name="steamid"></param>
        [RequiredParameter("steamid")]
        public void SteamId(long steamid)
        {
            Add("steamid", steamid);
        }
    }
}
